package com.ys.erp.stage_config_service.controller;

import com.ys.erp.framework.annotation.CheckEmpLogin;
import com.ys.erp.framework.annotation.ResponseResult;
import com.ys.erp.framework.annotation.StageLoginEmp;
import com.ys.erp.framework.bean.dto.StageEmpDTO;
import com.ys.erp.stage_config_service.bean.condition.ConfigCondition;
import com.ys.erp.stage_config_service.bean.condition.MallSettingCondition;
import com.ys.erp.stage_config_service.service.ConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lwj
 * @date 2025/5/19
 */
@ResponseResult
@RestController
@RequiredArgsConstructor
@RequestMapping("/manage/config")
@Tag(name = "配置相关接口", description = "配置相关接口")
public class ConfigController {

    private final ConfigService configService;

    @PostMapping("/setBuyInformation")
    @Operation(summary = "购买须知配置", description = "购买须知配置")
    @CheckEmpLogin
    public void setBuyInformation(@RequestBody @Valid ConfigCondition.SetBuyInformationCon con,
                                  @StageLoginEmp StageEmpDTO empDto) {
        configService.setBuyInformation(empDto, con);
    }

    @PostMapping("/setYsPulse")
    @Operation(summary = "设置幺豆抵扣比列", description = "设置幺豆抵扣比列")
    @CheckEmpLogin
    public void setYsPulse(@RequestBody @Valid ConfigCondition.SetYsPulseCon con,
                        @StageLoginEmp StageEmpDTO empDto) {
        configService.setYsPulse(empDto, con);
    }

    @PostMapping("/upMallSetting")
    @Operation(summary = "更新商城设置", description = "更新商城设置")
    public void upMallSetting(@RequestBody MallSettingCondition.UpMallSettingCon con) {
        configService.upMallSetting(con);
    }

}
